﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Affinity.Flux;
using Affinity.Synthesis;

namespace Service
{
    public class TimeSource : NotifyPropertyChangedBase
    {
        public TimeSource()
        {
            _timer = new Timer(param => CurrentTime = DateTime.Now, null, TimeSpan.Zero, TimeSpan.FromSeconds(1));
        }

        [Outlet(Contracts.Time.CurrentTime)]
        public DateTime CurrentTime
        {
            get { return _currentTime; }
            set
            {
                if (value == _currentTime) return;
                _currentTime = value;
                RaisePropertyChanged("CurrentTime");
            }
        }
        private DateTime _currentTime;

        private readonly Timer _timer;
    }
}
